$(document).ready(function() {

	var id = "caixaDataGrid";
	var aoColumns = [
	     			{"sTitle": "Abertura", "mDataProp": "dataAbertura", "sWidth": "180px", "bVisible": true, "sDefaultContent":""},
	     			{"sTitle": "Fechamento", "mDataProp": "dataFechamento", "sWidth": "80px", "bVisible": true, "sDefaultContent":""},
	     			{"sTitle": "Valor Abertura", "mDataProp": "valorAbertura", "sWidth": "60px", "bVisible": true, "sDefaultContent":""},
	     			{"sTitle": "Valor Fechamento", "mDataProp": "valorFechamento", "sWidth": "40px", "bVisible": true, "sDefaultContent":""},
	     			{"sTitle": "", "mDataProp": "htmlControl", "bSortable": false, "sWidth": "3px", "bVisible": false, "sDefaultContent":""}
	         ];
	oneToManyHeight(id, JSON.stringify(aoColumns, function(key, val) {if (typeof val === 'function') { return val + '';} return val;}), "300");
	carregaCaixas();	
});

function carregaCaixas(){
	
	$.ajax({
		"type": "GET",
		"contentType": "application/json",
		"url": "caixases?find=ByUsuario",
		"beforeSend": function(xhr,settings){
						
			$("#"+$("form").attr("id")).validationEngine('hide');
			$("#bg-corpo").block({message: "<img src='"+"img/ajax-loader.gif"+"'/> &nbsp;Carregando caixas já fechados...",
								 css: { 'border': '1px',
										'background': 'transparent',
										'color': 'black'
								      } 
							});
		},
		"error": trataErro,
		"complete": function(){
			$("#bg-corpo").unblock();
		},
		"success": function(data, textStatus, xhr){
			$("#caixaDataGrid").dataTable().fnAddData(data);
		}
	 });	
}

function imprimeCaixa(){
	
}